<template>
  <div class="item-box">
    <block-header icon="/static/icon/guiji.png" title='轨迹' :tags="tags"
                  :load="loadAll"></block-header>
    <axis-y :data="trackDataTemp" v-if="trackDataTemp.length > 0"></axis-y>
    <span class="tip-null" v-else>暂无数据</span>
  </div>
</template>

<script>
  import BlockHeader from '../../components/block-header'
  import AxisY from '../../components/axis-y'
  import request from '../../helper/request'

  export default {
    name: 'track-block',
    components: {
      BlockHeader,
      AxisY
    },
    mixins: [],
    computed: {},
    props: {
      data: {
        type: Object,
        default() {
          return {}
        }
      }
    },
    data() {
      return {
        trackData: [],
        trackDataTemp: [],
        tags: []
      }
    },
    methods: {
      /**
       * 查看全部
       */
      loadAll() {
        this.$store.commit('updatePhone', this.data)
        this.$router.push('/track-block-all')
      },
      getQueryList(limit = 5) {
        let param = Object.assign({
          'sjh': '',
          'gjlx': '00',
          'pageObj': {
            'currPage': 1,
            'pageSize': limit,
            'pagination': '1'
          }
        }, this.data)
        request('superRecord/mobile/gjxx', 'SC0424', param).then(res => {
          this.tags = [`真实轨迹(${res.real || 0})`, `疑似轨迹(${res.virual || 0})`]
          this.trackData = res.gjxxArr.map(resGJ => {
            return {
              time: resGJ.time,
              address: resGJ.dd
            }
          })
          this.trackDataTemp = this.trackData.slice(0, 5)
        }).catch(err => {
          this.$toast(err.msg)
        })
      }
    },
    watch: {},
    mounted() {
    },
    created() {
      this.getQueryList()
    }
  }
</script>

<style scoped>

</style>
